package com.py.chat.client.businese;

import com.py.chat.proto.IBusineseHandle;

import java.text.SimpleDateFormat;

import com.google.protobuf.MessageLite;
import com.py.chat.UI.UI;
import com.py.chat.proto.ChatProbuf.STCChatRet;

public class ClientChatRetHandle extends IBusineseHandle<STCChatRet>{

	@Override
	public MessageLite handle(STCChatRet msg) {
		int status = msg.getStatus();
		String message = msg.getMsg();

		//系统消息
		if(status == 0){
			UI.msgUI(message);
		}
		//用户消息
		if(status == 1){
			String sendUserName = msg.getChatLog().getSendUserName();
			int sendUserLevel = msg.getChatLog().getSendUserLevel();
			long createDate = msg.getChatLog().getCreateDate();
			String msgStr = msg.getChatLog().getMsg();
			SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss  ");
			String dateStr = df.format(createDate);
			UI.reMsgUI(dateStr, sendUserName, Integer.toString(sendUserLevel), msgStr);
		}
		return null;
	}

}
